/*
 * hashGen.h
 *
 *  Created on: Dec 13, 2012
 *      Author: hxin
 */

#ifndef HASHGEN_H_
#define HASHGEN_H_

#include "refAnalyser.h"
#include <vector>

using namespace std;

class hashGen: public refAnalyser {
public:
	hashGen() :
			refAnalyser() {
	}
	hashGen(string refFileName, string HTFileName, int KmerSize, int maxError =
			5) :
			refAnalyser(refFileName, KmerSize, maxError) {

		chrHashData = map<KmerHash, vector<unsigned int>,
				bool (*)(const KmerHash&, const KmerHash&)>(&KmerHash::compare);
		this->HTFileName = HTFileName;
		cout << "This->KmerSize: " << this->KmerSize << endl;
		cout << "This->maxError: " << this->maxError << endl;
	}

	hashGen(const hashGen& rhs) :
			refAnalyser(rhs) {
		chrHashData = rhs.chrHashData;
	}

	~hashGen() {
	}

	vector<unsigned long long> query(string read);
	vector<unsigned long long> query(string read,
			vector<unsigned long int>& conductedAF);
	void loadHash(int chrNum);
	void unloadHash();
	void printStat();

	void storePartialTable();
	void storeFullTable();

	bool searchKey(int target_coor, vector<unsigned int> & entry_coor,
			int errThreshold);

private:

	map<KmerHash, vector<unsigned int>,
			bool (*)(const KmerHash&, const KmerHash&)> chrHashData;
	map<KmerHash, vector<unsigned int>,
			bool (*)(const KmerHash&, const KmerHash&)>::iterator HTIter;
	string HTFileName;
};

#endif /* HASHGEN_H_ */
